package com.info.threads;

import org.apache.log4j.Logger;
import org.net.operation.TerServer;

import com.info.server.StartServer;

/**
 * @author HAHA
 * 
 */
public class ScanThread extends Thread {
	private static Logger logger = Logger.getLogger(ScanThread.class);
	boolean runflag = false;
	private TerServer listen = null;

	public ScanThread(TerServer server) {
		this.listen = server;
	}

	public void run() {
		while (!this.runflag)
			try {
				try {
					Thread.sleep(StartServer.pollquit / 2L);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
				try {
					if (this.listen != null)
						this.listen.clearTimeout();
					Thread.sleep(StartServer.pollquit / 2L);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
			} catch (Exception e) {
				logger.info("SHW#轮循过期终端出现错误");
				e.printStackTrace();
			}
	}

	public void clear() {
		try {
			this.runflag = true;
			interrupt();
		} catch (Exception localException) {
		}
	}
}